//
//  P13File.m
//  FindDuplicates
//
//  Created by Petur Ingi Egilsson on 8/15/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "P13File.h"

@implementation P13File

- (id)init
{
    self = [super init];
    if (self) {
    }
    
    return self;
}

-(id) initWithPath: (NSString *) path
{
    self = [super init];
    if (self) {
        NSFileManager *fm = [NSFileManager defaultManager];
        NSDictionary *fAttributes = [fm attributesOfItemAtPath:path error:nil];
        fOwner = [NSString stringWithString:[fAttributes fileOwnerAccountName]];
        fPath = [NSString stringWithString:path];
        fSize = [fAttributes fileSize];
        [fm release];
    }
    
    return self;
}

-(void) dealloc
{
    [fPath release];
    [fOwner release];
    [md5 release];
    [super dealloc];
}

-(NSString *) getPath
{
    return [NSString stringWithString:fPath];
}

-(NSString *) getOwner
{
    return [NSString stringWithString:fOwner];
}

-(unsigned long long) getSize
{
    return fSize;
}

-(void) calculateMD5
{
    md5 = [NSString stringWithString:[P13MD5File fileMD5:fPath]];
}

-(NSString *) getMD5
{
    return [NSString stringWithString:md5];
}

@end
